﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebPattern.Core;

namespace WebPattern.MVC.Controllers
{
    public class SwitchingCultureController : BaseController
    {
        public ActionResult ChangeCulture(string lang, string returnUrl)
        {
            if (returnUrl.Length >= 3)
            {
                returnUrl = returnUrl.Substring(1);
                if (returnUrl.Contains("/"))
                    returnUrl = returnUrl.Remove(0, returnUrl.IndexOf('/'));
                else
                    returnUrl = string.Empty;
            }
            return Redirect("/" + lang.ToString() + returnUrl);
        }
    }
}
